<template>
	<view class="screen-publish-1" :style="item.css">
		<view class="_top-recommend">
			<view class="_box">
				<view class="_text_1" :style="item.text_1_css">
					{{item.text_1[$i18n.locale]}}
				</view>
				<view class="_text_2" :style="item.text_2_css">
					{{item.text_2[$i18n.locale]}}
				</view>
				<view class="_text_3" :style="item.text_3_css">
					{{item.text_3[$i18n.locale]}}
				</view>
				<view class="post-list">
					<template v-if="listStatus === 'success'">
						<view
							v-for="item in list"
							@click="$_to('post/detail?pid=' + item.pid)">
							{{item.title?item.title:$_filterHtml(item.content)}}
						</view>
					</template>
					<template v-if="listStatus === 'loading'">
						<global-loading></global-loading>
					</template>
					<template v-if="listStatus === 'empty'">
						<view style="color: #C0C4CC;padding-bottom: 1rpx;">{{$t('listEmpty')}}</view>
					</template>
				</view>
				<view class="change-button" @click="clickChangeButton">
					<text class="iconfont icon-shuaxin"></text>
					<text>{{changeText}}</text>
				</view>
			</view>
		</view>
		<view class="_footer-button" v-if="item.button.length">
			<view
				v-for="item in item.button"
				@click="$_to(item.url)">
				<text :class="'iconfont ' + item.iconfont" :style="item.css"></text>
				<text class="text">{{item.text[$i18n.locale]}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"screen-publish-1",
		props:{
			item:{
				type:Object,
				default:null
			}
		},
		data() {
			return {
				list:[],
				listStatus:"loading",
				changeText:this.$t('refresh')
			};
		},
		mounted(){
			this.getList();
		},
		methods: {
			getList(){
				this.$_request(
					"GET", "/api/fresns/v1/post/list",
					{
						...this.item.listQuery,
						"page":1,
						"filterType":"whitelist",
						"filterKeys":"pid,title,content"
					},
					(res) => {
						if (res.data.data.list.length) {
							this.list = res.data.data.list;
							this.listStatus = "success";
						} else {
							this.listStatus = "empty";
						}
					}
				)
			},
			clickChangeButton(){
				this.listStatus = "loading";
				this.getList();
			},
		}
	}
</script>

<style lang="scss" scoped>
.screen-publish-1{
	width: 100%;
	//height: 100vh;
	height:calc(100vh - var(--window-top) - var(--window-bottom));
	._top-recommend{
		width: 100%;
		height:calc(100vh - var(--window-top) - var(--window-bottom));
		display: flex;
		align-items: center;
		justify-content: center;
		._box{
			display: flex;
			align-items: center;
			justify-content: center;
			flex-flow: column;
		}
		._text_1{
			font-size: 50rpx;
			line-height: 50rpx;
			font-weight: bold;
			padding-bottom: 35rpx;
			color: $placeholder;
		}
		._text_2{
			font-size: 50rpx;
			line-height: 50rpx;
			font-weight: bold;
			padding-bottom: 35rpx;
		}
		._text_3{
			font-size: 28rpx;
			line-height: 28rpx;
			padding-bottom: 35rpx;
			color: $placeholder;
		}
		.post-list{
			view{
				margin: 0 40rpx 40rpx 40rpx;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 1;
				overflow: hidden;
				font-size: 30rpx;
				line-height: 30rpx;
				text-align: center;
			}
		}
		.change-button{
			display: flex;
			align-items: center;
			line-height: 30rpx;
			text{
				font-size: 30rpx;
				color: $theme;
				font-weight: bold;
			}
			.iconfont{
				padding-right: 5rpx;
			}
		}
	}
	._footer-button{
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		left: 0;
		bottom: 0;
		padding-bottom: 25rpx;
		view{
			display: flex;
			align-items: center;
			justify-content: center;
			flex-flow: column;
			padding: 0 12.5rpx;
			.iconfont{
				display: flex;
				align-items: center;
				justify-content: center;
				background: $theme;
				line-height: 60rpx;
				font-size: 60rpx;
				color: #FFF;
				width: 110rpx;
				height: 110rpx;
				border-radius: 10rpx;
			}
			.text{
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 22rpx;
				line-height: 22rpx;
				padding-top: 10rpx;
			}
		}
	}
}
</style>